YARN-11290. Improve Query Condition of FederationStateStore#getApplicationsHomeSubCluster.#4846
YARN-11290. Improve Query Condition of FederationStateStore#getApplicationsHomeSubCluster.#4846goiri merged 30 commits intoapache:trunkfrom
Conversation
…ationsHomeSubCluster.
|
💔 -1 overall
This message was automatically generated. |
| appCount++; | ||
| } | ||
|
|
||
| GetApplicationsHomeSubClusterResponse.newInstance(result); |
There was a problem hiding this comment.
This line of code should be an extra line of code, which has no practical significance. The following is directly constructed and returned.
| SubClusterId requestSubClusterId = request.getSubClusterId(); | ||
| int appCount = 0; | ||
| for (int i = 0; i < applicationIdList.size(); i++) { | ||
| if (appCount >= maxAppsInStateStore) { |
There was a problem hiding this comment.
Actually it would be good to do a foreach
There was a problem hiding this comment.
Thanks for your suggestion, I will modify the code!
| if (requestSubClusterId != null && !requestSubClusterId.equals(subClusterId)){ | ||
| continue; | ||
| } | ||
| result.add(ApplicationHomeSubCluster.newInstance(applicationId, subClusterId)); |
There was a problem hiding this comment.
do the reverse if to avoid the continue
| try { | ||
| cstmt = getCallableStatement(CALL_SP_GET_APPLICATIONS_HOME_SUBCLUSTER); | ||
| cstmt.setInt("limit_IN", maxAppsInStateStore); | ||
| String homeSubClusterIN = null;; |
| // If the requestSubClusterId that needs to be filtered in the request | ||
| // is inconsistent with the SubClusterId in the data, continue to the next round | ||
| if (requestSubClusterId != null && !requestSubClusterId.equals(homeSubCluster)) { | ||
| continue; |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
This PR changes the execution script of the stored procedure, I will check the script against the major version of the database. SQLServer
MySQL MySQL-5.5 and MySQL-5.6 Can't Create Table membership and policies, for the following reasons: 1.The primary key of the membership table is subClusterId varchar(256) , Mysql will prompt the following error: 2.The primary key of the policies table is subClusterId varchar(256) , Mysql will prompt the following error:
|
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@goiri Please help to review the code again, thank you very much! |
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@goiri Please help to review the code again, thank you very much! This PR changes the execution script of the stored procedure, I will check the script against the major version of the database. SQLServer
MySQL MySQL-5.5 and MySQL-5.6 Can't Create Table membership and policies, for the following reasons: 1.The primary key of the membership table is subClusterId varchar(256) , Mysql will prompt the following error: 2.The primary key of the policies table is subClusterId varchar(256) , Mysql will prompt the following error:
|
|
🎊 +1 overall
This message was automatically generated. |
| private boolean judgeAdd(SubClusterId filterSubCluster, SubClusterId homeSubCluster) { | ||
| if (filterSubCluster == null) { | ||
| return true; | ||
| } else if (filterSubCluster.equals(homeSubCluster)) { |
There was a problem hiding this comment.
Thanks for your help reviewing the code, I will modify the code.
| return null; | ||
| } | ||
|
|
||
| private boolean judgeAdd(SubClusterId filterSubCluster, SubClusterId homeSubCluster) { |
There was a problem hiding this comment.
judgeAdd is a weird name fot this function.
There was a problem hiding this comment.
I will re-select an appropriate method name.
| * | ||
| * @return the subcluster identifier | ||
| */ | ||
| @InterfaceAudience.Public |
|
|
||
| Set<ApplicationHomeSubCluster> appHomeSubClusters = new HashSet<>(); | ||
|
|
||
| for (int i = 0; i < 10; i++) { |
...src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java
Show resolved
Hide resolved
| mockRMs.put(subClusterId, mockRM); | ||
| } | ||
| initNodeAttributes(subClusterId, mockRM); | ||
| initReservationSystem(mockRM); |
There was a problem hiding this comment.
This seems out of scope.
Should we do it in a separate PR?
There was a problem hiding this comment.
I will submit pr separately to improve this code.
There was a problem hiding this comment.
The new pr will optimize the repetitive submission of reservations and refactor some test code.
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
@goiri Please help to review the code again, thank you very much! I have provided a test report, we can refer to the following link MySQL
SQLServer
|
| IF(homeSubCluster_IN = '', 1, (homeSubCluster = homeSubCluster_IN)) AS filter_result | ||
| FROM applicationshomesubcluster | ||
| ORDER BY createTime DESC) AS app_home_sc | ||
| WHERE filter_result = 1 |
There was a problem hiding this comment.
Why you cannot do:
SELECT
applicationId,
homeSubCluster,
createTime
FROM applicationshomesubcluster
WHERE homeSubCluster_IN = '' OR homeSubCluster = homeSubCluster_IN
There was a problem hiding this comment.
Thank you very much for your suggestion, I agree with you, I will modify the code.
| [createTime], | ||
| row_number() over(partition by [homeSubCluster] order by [createTime] desc) AS app_rank | ||
| FROM [dbo].[applicationsHomeSubCluster] | ||
| WHERE [homeSubCluster] = @homeSubCluster) AS t |
There was a problem hiding this comment.
Why not
WHERE [homeSubCluster] = @homeSubCluster OR @homeSubCluster = ''
There was a problem hiding this comment.
My code is a bit complicated, your approach is really good.
|
💔 -1 overall
This message was automatically generated. |
.../java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java
Show resolved
Hide resolved
| return null; | ||
| } | ||
|
|
||
| private boolean filterHomeSubCluster(SubClusterId filterSubCluster, |
There was a problem hiding this comment.
We have this function defined three times in three places.
It should also be static.
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
| [createTime], | ||
| row_number() over(order by [createTime] desc) AS app_rank | ||
| FROM [dbo].[applicationsHomeSubCluster] | ||
| WHERE [homeSubCluster] = @homeSubCluster OR @homeSubCluster = '') AS t |
There was a problem hiding this comment.
In the other one we use AS applicationshomesubcluster; let's try to be consistent with the names as possible.
There was a problem hiding this comment.
Thank you very much for helping to review the code, I will modify the code.
|
🎊 +1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@goiri Can you help merge this pr into trunk branch? Thank you very much! after this pr is completed, I will submit a new pr to clean up the completed application in the router's StateStore. |
|
@goiri Thank you very much for your help reviewing the code! |
…ationsHomeSubCluster. (apache#4846)
JIRA: YARN-11290. Improve Query Condition of FederationStateStore#getApplicationsHomeSubCluster.